import { useAppDispatch } from "@/hook/useRedux"
import { NewTask } from "./NewTask"
import { addSubTaskChecklist } from "@/redux/tasks/tasksSlice"
import { useState } from "react";

interface Props {
  setOpen(bool: boolean): void;
  aiShow?: boolean;
  parentId: number;
  columnId: string;
  grandParentId: number;
}

export const NewChecklist = ({ setOpen, aiShow = true, parentId, columnId, grandParentId }: Props) => {
  const dispatch = useAppDispatch()
  const [sendBtn, setSendBtn] = useState(false)

  const postTask = (other: any) => {
    dispatch(addSubTaskChecklist({ other, parentId, columnId, grandParentId })).then(() => {
      setOpen(false)
      setSendBtn(false)
    })
  }

  return <NewTask sendBtn={sendBtn} setSendBtn={setSendBtn} setOpen={setOpen} postTask={postTask} aiShow={aiShow} />

}